package cvc.sync;

public class Improc implements Runnable {

	int currMatrix = 0;

	void processImage() {
		Holder<Integer> currImage = new Holder<Integer>();
		Main.capturer.getImage(currImage);

		try {
			// TODO: JNI image process
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			// TODO: handle exception
		}
		setMatrix(currImage.value);
	}

	private void setMatrix(int v) {
		synchronized (this) {
			currMatrix = v;
		}
	}

	void getMatrix(Holder<Integer> conteiner) {
		synchronized (this) {
			conteiner.value = currMatrix;
		}
	}

	@Override
	public void run() {
		while (true) {
			processImage();
			System.out.println(this.getClass().getName());
		}
	}

}
